import axios from 'axios'
import baseUrl from '../../util/url.js'
const url = baseUrl + 'api.php/records/shopcar'
const payorderurl = baseUrl + 'api.php/records/payorder'

export default {
    namespaced:true,
    state:{

    },
    mutations:{

    },
    actions:{
        getlist({ state, commit, dispatch }, id) {
            return new Promise((resolve, reject) => {
                axios({
                    method: 'get',
                    url,
                    // params: {filter:'id,eq,'+id}
                }).then(res => {
                    resolve(res.data.records)
                }).catch(e => {
                    reject()
                })
            });
        },
        postOrder(context,obj){
            return new Promise((resolve, reject) => {
                axios({
                    method: 'post',
                    url:payorderurl,
                    data:{
                        uid: obj.uid,
                        content:obj.obj
                    }
                }).then(res => {
                    resolve()
                }).catch(e => {
                    reject()
                })
            });
        },
        deleteList(context, id) {
            return new Promise((resolve, reject) => {
                axios({
                    method: 'delete',
                    url:url + '/' + id,
                })
            });
        },
    }
}